﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using GreatB2C.Config.SiteInfo;

namespace GreatB2C.Web.Manage.SystemSet.SiteInfo
{
    public partial class IPLimitSet : Inherit.ManagePage
    {
        protected void Page_Load( object sender , EventArgs e )
        {
            if ( !IsPostBack )
            {
                LoadSetting( );
            }
        }

        protected void LoadSetting( )
        {
            radLockIPType.SelectedValue = IPConfig.LockIPType.ToString( );
            txtIPLockWhite.Text = IPConfig.IPLockWhite.ToString( );
            txtIPLockBlack.Text = IPConfig.IPLockBlack.ToString( );
            radAdminLockIPType.SelectedValue = IPConfig.AdminLockIPType.ToString( );
            txtIPLockAdminWhite.Text = IPConfig.IPLockAdminWhite.ToString( );
            txtIPLockAdminBlack.Text = IPConfig.IPLockAdminBlack.ToString( );
        }

        protected void BtnSubmit_Click( object sender , EventArgs e )
        {
            bool isSuccess = IPConfig.Config( radLockIPType.SelectedValue.ToString( ) , txtIPLockWhite.Text.Trim( ) , txtIPLockBlack.Text.Trim( ) , radAdminLockIPType.SelectedValue.ToString( )
            , txtIPLockAdminWhite.Text.Trim( ) , txtIPLockAdminBlack.Text.Trim( ) );

            if ( isSuccess )
            {
                Response.Redirect( "../../Message.aspx?msg=" + Server.UrlEncode( "IP段限制配置成功！" ) + "&rtn=SystemSet/SiteInfo/IPLimitSet.aspx" );
            }
            else
            {
                Response.Redirect( "../../Message.aspx?msg=" + Server.UrlEncode( "IP段限制配置失败，请联系管理员！" ) + "&rtn=SystemSet/SiteInfo/IPLimitSet.aspx" );
            }
        }
    }
}
